package com.qiuhui.springboot01.controller;

import com.qiuhui.springboot01.entity.Book;
import com.qiuhui.springboot01.mapper.BookMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName: BookController
 * @Description: TODO
 * @author: tian
 * @date: 2021/4/10  2:32 下午
 */
@RestController
public class BookController {

    @Autowired
    BookMapper bookMapper;

    @RequestMapping(value = "/book",method = {RequestMethod.GET})
    public List<Book> getBook(){
        List<Book> list = bookMapper.getBook();
        System.out.println(list);
        return list;
    }

    @RequestMapping("/queryById/{id}")
    public Book queryById(@PathVariable("id") Integer id){
        Book book = bookMapper.getBookById(id);
        return book;
    }
}
